<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <script src="../js/flexible.js"></script>
    <title>发布详情</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/job/style.css">
    <style>
        #pullUp{
            display: none !important;
        }
    </style>
</head>

<body>
    <div id="J_wrapper" class="container">
        <div id="scroller">
            <div id="pullDown">
                <span class="pullDownIcon"></span><span class="pullDownLabel">下拉刷新</span>
            </div>
            <!-- 已结束 -->
            <div class="differ_pages" style="display:block;">
                <div class="list_wrap">
                    <div class="list_box" id="J-head">
                    </div>
                </div>
                <div class="tabs-wrapper">
                    <div class="time_box clearfix hide" id="J-time-box">
                        <span class="each_time">￥<span id="J-eachTime"></span>/时</span>
                        <a class="j_task_end btns change_bg_col" href="javascript:;">结束</a>
                        <a class="j_task_alter btns" href="javascript:;">修改</a>
                    </div>
                    <div class="tabs">
                        <ul class="tab_list clearfix">
                            <li><a data-mark="0" class="ago active_blue" href="javascript:;">已报名<span class="num"><em class="change_num j-baoming-no"></em>/<span class="j-sumno"></span></span></a><i class="triangle"></i></li>
                            <li><a data-mark="6" class="ago bor_line" href="javascript:;">已签到<span class="num"><em class="change_num j-qiandao-no"></em>/<span class="j-sumno"></span></span></a><i></i></li>
                            <li><a data-mark="7" class="ago" href="javascript:;">已签退<span class="num"><em class="change_num j-qiantui-no"></em>/<span class="j-sumno"></span></span></a><i></i></li>
                        </ul>
                    </div>
                </div>
                <!-- 已报名 -->
                <div class="j_lists">
                    <ul class="texts_box">
                    </ul>
                </div>
                <!--  end -->
                <!-- 已签到 -->
                <div class="j_lists hide">
                    <div class="header">
                        <ul class="clearfix">
                            <li><i class="icos"></i></li>
                            <li><i class="icos bag_ico"></i></li>
                        </ul>
                    </div>
                    <div class="mid_content">
                        <ul class="texts_box">
                        </ul>
                    </div>
                    <div class="footer hide" id="J-footer2">
                        <ul class="clearfix">
                            <li>
                                <div class="checkBox_ico"><i class="active_check"></i></div><span class="all_select">全选</span></li>
                            <li><a class="sure_signed j-qiandao" style="display: block;" href="javascript:;">确认签到</a></li>
                        </ul>
                    </div>
                </div>
                <!--  end -->
                <!-- 已签退 -->
                <div class="j_lists hide">
                    <div class="header alter_header">
                        <ul class="clearfix">
                            <li><i class="icos"></i></li>
                            <li><i class="icos bag_ico"></i></li>
                            <li><i class="icos money_bag"></i></li>
                        </ul>
                    </div>
                    <div class="mid_content">
                        <ul class="texts_box">
                        </ul>
                    </div>
                    <div class="footer hide" id="J-footer">
                        <ul class="clearfix">
                            <li>
                                <div class="checkBox_ico"><i class="active_check"></i></div><span class="all_select">全选</span></li>
                            <li><a class="sure_signed btn_salary hide j-salary" href="javascript:;">发放工资</a></li>
                            <li><a class="sure_signed hide j-qiandao" href="javascript:;">确认签到</a></li>
                            <li><a class="sure_signed alter_signed hide j-qiantui" href="javascript:;">确认签退</a></li>
                        </ul>
                    </div>
                </div>
            </div>
            <!--  end -->
            <div id="pullUp">
                <span class="pullUpIcon"></span><span class="pullUpLabel"></span>
            </div>
        </div>
    </div>
    <!-- 弹窗 -->
    <div id="J_salaryWin" class="window_rgb">
        <div class="window_box">
            <a class="j-close close" href="javascript:;"></a>
            <span class="total_salary">工资总金额：<span id="J_salary_count"></span>元</span>
            <a class="salaryBtn" href="javascript:;">确认发放</a>
        </div>
    </div>
</body>
<script src="../js/jquery.min.js"></script>
<script src="../js/fastclick.js"></script>
<script src="../js/scroll/iscroll.js"></script>
<script src="../js/scroll/scroll-init.js"></script>
<script src="../js/ajax/jsencrypt.js"></script>
<script src="../js/ajax/ajax.js"></script>
<script src="../js/main.js"></script>
<script type="text/javascript">
//报名
function baoMing(data) {
    var arr = [];
    var yea = (data.m_created_at).substr(0, 10).replace(/-/g, ".");
    var tim = (data.m_created_at).substr(11, 5);
    if (data.wo_sex == 0) {
        data.wo_sex = "女";
    } else {
        data.wo_sex = "男";
    }
    arr.push('<li><p class="p1 clearfix"><span class="nam">' + data.w_name + '</span><span class="sex">' + data.wo_sex + '</span>');
    arr.push('<span class="tel">联系电话:' + data.w_phone + '</span></p>');
    arr.push('<p class="p2 clearfix">' + data.w_idcar + '<span class="date_box clearfix"><span class="years">' + yea + '</span>');
    arr.push('<span class="times">' + tim + '</span></span></p>');
    arr.push('</li>');
    return arr.join(' ');
}
//签到
function qianDao(data) {
    var arr2 = [];
    var work_yea = (data.m_enterprise_in_time).substr(0, 10).replace(/-/g, ".");
    var work_tim = (data.m_enterprise_in_time).substr(11, 5);
    var manage_year = (data.m_manage_in_time).substr(0, 10).replace(/-/g, ".");
    var yea = (data.m_worker_in_time).substr(0, 10).replace(/-/g, ".");
    var tim = (data.m_worker_in_time).substr(11, 5);
    var manage_time = (data.m_manage_in_time).substr(11, 5);
    arr2.push('<li class="clearfix" data-id="' + data.m_worker_id + '">');
    if (curStatus == "2") {
        arr2.push('<div class="left_box list_checkBox_ico"><i class="checkR"></i></div>');
    }
    arr2.push('<div class="no_checkB">');
    arr2.push('<p class="name_tel clearfix">' + data.w_name + '<i class="tele">(' + data.w_phone + ')</i><span class="work_year flo_right">' + yea + '<i class="work_time">' + tim + '</i></span></p>');
    arr2.push('<p class = "name_tel clearfix">平台管理员<span class = "work_year flo_right" >' + manage_year + '<i class = "work_time" >' + manage_time + '</i>');
    arr2.push('</span ></p><p class = "name_tel clearfix" >企业管理员<span class = "work_year flo_right" >' + work_yea + '<i class = "work_time" >' + work_tim + '</i></span></p>');
    arr2.push('</div></li>');
    return arr2.join(' ');
}
//签退
function qianTui(data) {
    var arr3 = [];
    var work_yea = (data.m_enterprise_out_time).substr(0, 10).replace(/-/g, ".");
    var work_tim = (data.m_enterprise_out_time).substr(11, 5);
    var manage_year = (data.m_manage_out_time).substr(0, 10).replace(/-/g, ".");
    var manage_time = (data.m_manage_out_time).substr(11, 5);
    var m_work_year = (data.m_worker_out_time).substr(0, 10).replace(/-/g, ".");
    var m_work_tim = (data.m_worker_out_time).substr(11, 5);
    arr3.push('<li class="clearfix" data-id="' + data.m_worker_id + '">');
    if (curStatus == "2" || curStatus == "3") {
        arr3.push('<div class="left_box list_checkBox_ico"><i class="checkR"></i></div>');
    }
    arr3.push(' <div class="alter_wid">');
    arr3.push('<p class="name_tel clearfix"><span class="name">' + data.w_name + '<i class="tele">(' + data.w_phone + ')</i></span><span class="work_year">' + m_work_year + '<i class="work_time">' + m_work_tim + '</i>');
    arr3.push('<i class="salarys">' + data.m_priceall + '元</i></span></p>');
    arr3.push('<p class="name_tel clearfix"><span class="name">平台管理员</span><span class="work_year ">' + manage_year + '<i class="work_time">' + manage_time + '</i></span></p>');
    arr3.push('<p class="name_tel clearfix"><span class="name">企业管理员</span><span class="work_year ">' + work_yea + '<i class="work_time">' + work_tim + '</i></span></p>');
    arr3.push('</div></li>');
    return arr3.join(' ');
}
//报名 签到 签退选项卡
var manageId = 2;
var userType = 2;
var isMsg = 0;
var taskId;
var curStatus; //用于存放当前的状态值

if (GetQueryString("userId")) {
    manageId = GetQueryString("userId"); //获取当前会话的id
}
if (GetQueryString("type")) {
    userType = GetQueryString("userType"); //获取当前的用户类型
}

if (localStorage.getItem("isMsgList")) {
    isMsg = 1;
    localStorage.setItem("isMsgList", "");
}
if (localStorage.getItem("data_taskId")) {
    taskId = localStorage.getItem("data_taskId");
}


var obj = {},
    _type, //当前选项卡的值
    ind, //当前的索引 
    cur = 0,
    now;
var firstRender = true; //第一次需要渲染头部
var stateObj = {};

if (localStorage.getItem("o_flag")) {
    cur = localStorage.getItem("o_flag");
}
$(".tabs").delegate('li', 'click', function() {
    now = $(this);
    var dest = now.parents(".tabs");
    ind = now.index();
    _type = now.find("a").attr("data-mark");
    localStorage.setItem("o_flag", ind);

    dest.find("li").eq(ind).find("a").addClass("active_blue").parent().siblings().children("a").removeClass("active_blue");
    dest.find("li").eq(ind).find("i").addClass("triangle").parent().siblings().children("i").removeClass("triangle");
    now.parents(".tabs-wrapper").siblings(".j_lists").eq(ind).show().siblings(".j_lists").hide();

    //控制第一次的请求
    if (!obj[_type]) {
        pullUpAction();
        obj[_type] = true;
    }

}).find("li").eq(cur).trigger('click');

function renderHeader(data) {
    var arr = [];
    curStatus = data.status_id;
    //curStatus = 2;
    arr.push('<h4 class="tit_box clearfix" id="J-desc-id" data-id="' + data.id + '"> ');
    arr.push('<span class="tit1">' + data.c_name_ + '</span>');
    arr.push('<span class="tit2 ');
    if (curStatus == "1") {
        arr.push('zping');
        $("#J-eachTime").html(data.price);
        $("#J-time-box").show();
    } else if (curStatus == "2") {
        arr.push('working');
        $("#J-footer").show();
        $("#J-footer2").show();
        $(".j-qiantui").show().css("display", "block");
    } else if (curStatus == "3") {
        arr.push('paying');
        $("#J-footer").show();
        $(".j-salary").show().css("display", "block");
    } else if (curStatus == "4") {
        arr.push('ending');
    } else if (curStatus == "10") {
        arr.push('zending');
    }
    arr.push(' ">' + data.t_1_name_ + '</span>');
    arr.push('</h4>');
    if (curStatus != "1") {
        arr.push('<div class="join_box change_join_box">');
        arr.push('<span class="moneyT change_position">￥' + data.price + '/时</span>');
        arr.push('</div>');
    }

    arr.push('<div class="txt_box">');
    arr.push('<p><i class="time_ico"></i><span class="long-desc">' + data.start_time + ' - ' + data.end_time + '</span></p>');
    arr.push('<p><i class="man_ico"></i>' + data.contacts + '</p>');
    arr.push('<p><i class="tel_ico"></i>' + data.phone + '</p>');
    arr.push('<p><i class="copy_ico"></i><span class="long-desc">车费:' + data.car_subsidy + '元'+'<span>用餐时间:' + data.dinner_time + '分钟</span>'+'<span>其他:' + data.other_subsidy + '元</span></span></p>');
    arr.push('</div>');
    $("#J-head").html(arr.join(''));
    $(".j-sumno").html(data.number);

}

//已报名，已签到，已签退tab的请求数据接口
function pullUpAction() {
    if(stateObj[_type]){
        return false;
    }
    if (!obj[_type + "no"]) {
        obj[_type + "no"] = 1;
    } else {
        obj[_type + "no"]++;
    }
    start.postAjaxReq({
        param: {
            "id": manageId,
            "task_id": taskId,
            "type": userType,
            "status": _type,
            "page": obj[_type + "no"],
            "msg": isMsg
        },
        type: "GET",
        url: "/task/getTaskInfo",
        success: function(data) {
            var meta = data.result.joinList.meta;
            var html = '',
                now;
            var dataList = data.result.joinList.data;
            if (firstRender) {
                renderHeader(data.result); //渲染头部信息
                firstRender = false;
            }
            if (dataList.length > 0) {
                for (var i = 0; i < dataList.length; i++) {
                    now = dataList[i];
                    if (ind == 0) {
                        html += baoMing(now);
                    } else if (ind == 1) {
                        html += qianDao(now);
                    } else if (ind == 2) {
                        html += qianTui(now);
                    }
                }
                $(".texts_box:visible").append(html);

            } else if (obj[_type + "no"] == 1 && dataList.length == 0) {
                html = shoNoData();
                $(".texts_box:visible").append(html);
                stateObj[_type] = true;
                return false;
            }
            if (meta.current_page == meta.total_pages) {
                showFadeData();
                stateObj[_type] = true;
            }
            myScroll.refresh();
        },
        errorCb: function(data) {}
    });
};
$(document).ready(function() {
    FastClick.attach(document.body);
    //获取 统计信息
    start.postAjaxReq({
        param: {
            "id": manageId,
            "task_id": taskId,
            "type": userType
        },
        type: "GET",
        url: "/task/joinNum",
        success: function(data) {
            var obj = data.result.data;
            $(".j-baoming-no").html(obj.count);
            $(".j-qiandao-no").html(obj.signin);
            $(".j-qiantui-no").html(obj.signout);
        }
    })
})
</script>

</html>
